package com.sharding.demo.nproxy.config;



import java.lang.reflect.Proxy;

/**
 * @Author hu xu hong
 * @Date 2023/4/3 14:19
 */
public class MapperProxyFactory<T>{

    public  T newInstance(MapperProxy mapperProxy){
      return  (T)Proxy.newProxyInstance(mapperProxy.getMapperInterface().getClassLoader(),new Class[]{mapperProxy.getMapperInterface()},mapperProxy);
    }

    public  T newInstance(Class<T> mapperInterface ) {
        MapperProxy<T> mapperProxy = new MapperProxy(mapperInterface);
        return newInstance(mapperProxy);
    }
}
